package com.wrb.manage.service;

import com.wrb.manage.mapper.PointsMapper;
import com.wrb.manage.model.Points;
import com.wrb.manage.model.PointsCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author wrb
 * @date 2019/12/5 18:02
 */
@Service
public class PointsService {

	@Autowired
	private PointsMapper pointsMapper;

	public Points getByCustomerId(long customerId) {
		PointsCriteria criteria = new PointsCriteria();
		criteria.or().andCustomerIdEqualTo(customerId);
		List<Points> pointsList = pointsMapper.selectByExample(criteria);
		if (CollectionUtils.isEmpty(pointsList)) {
			return null;
		}
		return pointsList.get(0);
	}
}
